'use strict';

let
    Koa = require('koa'),
    port = 3456,
    app = new Koa(),
    middleWareFile = require('./tempMiddleWare'),
    router = require('koa-router')();


router.get('/', async ctx => {
    await ctx.render('./forin.html', {
        username: 'GiGi',
        num: 4,
        userArr: [
            { id: 1, name: 'GiGi', age: 20 },
            { id: 2, name: 'Curry', age: 32 },
            { id: 3, name: 'David', age: 40 },
            { id: 4, name: 'Noe', age: 35 }
        ],
        str: "hello world"
    })
})

app.use(middleWareFile);

// app.use(async (ctx, next) => {
//     ctx.render('./index.html', { name: 'Divad' })
// })

app.use(router.routes());

app.listen(port);

console.log(`http://localhost:${port}`);